Shader "GPUAnimation/GPUAnimationUnlit"
{
    Properties
    {
        [NoScaleOffset]_MainTex ("Texture", 2D) = "white" {}
        [NoScaleOffset]_AnimatedBoneMatrices ("AnimatedBoneMatrices", 2D) = "white" {}
        _SizeWidth ("SizeWidth", Float) = 0
        _SizeHeight ("SizeHeight", Float) = 0
    }

    CGINCLUDE
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it uses non-square matrices
#pragma exclude_renderers gles
    #include "UnityCG.cginc"
    #include "Assets/GPUAnimationLib/Shader/GPUAnimationLib.cginc"

    struct appdata
    {
        float4 vertex : POSITION;
        float2 uv : TEXCOORD0;
        float4 uv2 : TEXCOORD1;
        float4 uv3 : TEXCOORD2;
        UNITY_VERTEX_INPUT_INSTANCE_ID
    };

    struct v2f
    {
        float2 uv : TEXCOORD0;
        float4 vertex : SV_POSITION;
    };

    sampler2D _MainTex;
    float4 _MainTex_ST;
    uniform sampler2D _AnimatedBoneMatrices;
    uniform float _SizeWidth;
    uniform float _SizeHeight;
    UNITY_INSTANCING_BUFFER_START(Props)
    UNITY_DEFINE_INSTANCED_PROP(float4x4, _AnimationState)
    UNITY_INSTANCING_BUFFER_END(Props)

    v2f vert(appdata v)
    {
        UNITY_SETUP_INSTANCE_ID(v);
        v2f o;
        float3 pos;
        float2 size = float2(_SizeWidth, _SizeHeight);
        AnimateBlendUnlit(v.vertex, float2x4(v.uv2, v.uv3), _AnimatedBoneMatrices, size,
                           UNITY_ACCESS_INSTANCED_PROP(Props, _AnimationState), pos);
        o.vertex = UnityObjectToClipPos(float4(pos, v.vertex.w));
        o.uv = TRANSFORM_TEX(v.uv, _MainTex);
        return o;
    }

    fixed4 frag(v2f i) : SV_Target
    {
        fixed4 col = tex2D(_MainTex, i.uv);
        return col;
    }
    ENDCG

    SubShader
    {
        Tags
        {
            "RenderType"="Opaque"
        }
        //LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing
            ENDCG
        }
    }
}